import { FriendStyle } from "./FriendStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { TilePanel } from "../equipment/TilePanel";
import { FriendCellRenderer } from "./FriendCellRenderer";
import { FriendRecentTalkCellRender } from "./FriendRecentTalkCellRender";
import { FriendIntimateCellRenderer } from "./FriendIntimateCellRenderer";
import { FriendCellRenderer2 } from "./FriendCellRenderer2";
import { Language } from "../../../../extend/language/Language";
import { FriendInfo } from "../../model/FriendInfo";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { PlayerMiniInfo } from "../../model/PlayerMiniInfo";
import { Vector } from "../../../../__AS3__/vec/Vector";
type int = number;
//class FriendsList
    
    export  class FriendsList /* flash.display.Sprite */
    {
        constructor(arg1: string="")
        {
            
            this._name = arg1;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.initNode();
            this.initList();
            return;
        }

        /* internal  */initNode(): void
        {
            this._node = new Object /* flash.display.Sprite */();
            this.addChild(this._node);
            this._textNode = new Object /* flash.text.TextField */();
            this._textNode.defaultTextFormat = FriendStyle.textFormat2;
            this._textNode.width = 120;
            this._textNode.height = 30;
            this._textNode.selectable = false;
            this._textNode.x = 10;
            this._textNode.filters = [FilterConst.nameGlowFilter];
            this._node.addChild(this._textNode);
            this.refreshTitle(0, 0);
            return;
        }

        /* internal  */initList(): void
        {
            this._friendTileList = new TilePanel();
            this._friendTileList.setSize(195, 250);
            this._friendTileList.rowHeight = this.isFriendTab() ? 35 : 20;
            this._friendTileList.columnWidth = 165;
            var loc1=FriendCellRenderer;
            if (this._name != FriendsList.friend) 
            {
                if (this._name != FriendsList.intimatefriend) 
                {
                    if (this._name == FriendsList.recent) 
                    {
                        loc1 = FriendRecentTalkCellRender;
                    }
                }
                else 
                {
                    loc1 = FriendIntimateCellRenderer;
                }
            }
            else 
            {
                loc1 = FriendCellRenderer2;
            }
            this._friendTileList.setStyle("cellRenderer", loc1);
            this._friendTileList.y = 20;
            this.addChild(this._friendTileList);
            return;
        }

        /* internal  */isFriendTab(): Boolean
        {
            return this._name == FriendsList.friend || this._name == FriendsList.intimatefriend;
        }

        /* internal  */refreshTitle(arg1: int, arg2: int): void
        {
            var loc1=this._name;
            switch (loc1) 
            {
                case FriendsList.friend:
                {
                    this._textNode.text = Language.getString(40369) + "(" + arg1.toString() + "/" + arg2.toString() + ")";
                    break;
                }
                case FriendsList.intimatefriend:
                {
                    this._textNode.text = Language.getString(40408) + "(" + arg1.toString() + "/" + arg2.toString() + ")";
                    break;
                }
                case FriendsList.enemy:
                {
                    this._textNode.text = Language.getString(40370) + "(" + arg1.toString() + "/" + arg2.toString() + ")";
                    break;
                }
                case FriendsList.blackList:
                {
                    this._textNode.text = Language.getString(40371) + "(" + arg1.toString() + "/" + arg2.toString() + ")";
                    break;
                }
                case FriendsList.recent:
                {
                    this._textNode.text = Language.getString(40372) + "(" + arg1.toString() + "/" + arg2.toString() + ")";
                    break;
                }
            }
            return;
        }

        public refreashDataList(arg1: Vector.<FriendInfo>, arg2: Boolean=false): void
        {
            var loc3=null;
            var loc1=new DataProvider();
            var loc2=0;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                if (arg2 && loc3.friendPlayerInfo.online || !arg2) 
                {
                    loc1.addItem(loc3);
                }
                if (!loc3.friendPlayerInfo.online) 
                {
                    continue;
                }
                ++loc2;
            }
            this.refreshTitle(loc2, arg1 ? arg1.length : 0);
            this._friendTileList.dataProvider = loc1;
            this._friendTileList.drawNow();
            this._friendTileList.validateNow();
            return;
        }

        public refreashDataList2(arg1: Vector.<PlayerMiniInfo>, arg2: Boolean=false): void
        {
            var loc3=null;
            var loc1=new DataProvider();
            var loc2=0;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                if (arg2 && loc3.online || !arg2) 
                {
                    loc1.addItem(loc3);
                }
                if (!loc3.online) 
                {
                    continue;
                }
                ++loc2;
            }
            this.refreshTitle(loc2, arg1 ? arg1.length : 0);
            this._friendTileList.dataProvider = loc1;
            this._friendTileList.drawNow();
            this._friendTileList.validateNow();
            return;
        }

        public get friendTileList(): TilePanel
        {
            return this._friendTileList;
        }

        public static /* const */friend: string="Firend";

        public static /* const */intimatefriend: string="intimateFriend";

        public static /* const */enemy: string="Enemy";

        public static /* const */blackList: string="BlackList";

        public static /* const */recent: string="Recent";

        /* internal */ /* var */_node: Object /* flash.display.Sprite */;

        /* internal */ /* var */_textNode: Object /* flash.text.TextField */;

        /* internal */ /* var */_friendTileList: TilePanel;

        /* internal */ /* var */_name: string;
    }
